﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Xsl;
using System.Xml;
using System.Text;
using System.IO;

namespace Tesla.Web.Controls
{
    public partial class Menu : System.Web.UI.UserControl
    {
        
        public string XmlFileName
        {
            get;
            set;
        }
        public string XslFileName
        {
            get;
            set;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string XslSystemFileName = Server.MapPath(VirtualPathUtility.ToAbsolute("~//Xsl//" + XslFileName));
            XslTransform xslt = new XslTransform();
            xslt.Load(XslSystemFileName);
            
            string XmlSystemFileName = Server.MapPath(VirtualPathUtility.ToAbsolute("~//Xsl//" + XmlFileName));
            XmlDocument xDoc = new XmlDocument(); 
            xDoc.Load(XmlSystemFileName);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            xslt.Transform(xDoc, null, sw, null);

            MenuPlaceHolder.Text = sb.ToString();
        }
    }
}